import 'package:floor/floor.dart';
import 'package:flutter_getx/app/data/db/entity/group.dart';

@dao
abstract class GroupDao {
  @Query('SELECT * FROM GroupEntity')
  Future<List<GroupEntity>> findAllGroups();

  @Query('SELECT * FROM GroupEntity WHERE id = :id')
  Stream<GroupEntity?> findGroupById(int id);

  @insert
  Future<void> insertGroup(GroupEntity group);

  @insert
  Future<void> insertGroups(List<GroupEntity> groups);

  @Update(onConflict: OnConflictStrategy.replace)
  Future<void> updateGroup(GroupEntity group);

  @delete
  Future<void> deleteGroup(GroupEntity group);

  @delete
  Future<int> deleteGroupList(List<GroupEntity> list);

  @Query('delete from GroupEntity')
  Future<void> deleteAll();
}
